<template>
	<view class="card-content">
		<u-navbar :title="$t('电子名片')" @rightClick="rightClick" :autoBack="true" />
		<view style="width: 100%;height: 100rpx;"></view>
		<image style="width: 286rpx;height: 286rpx;margin-top: 150rpx;" src="@/static/index2/index25.png" mode="" />
		<!-- <view style="color: #999999;font-size: 24rpx;margin-top: 41rpx;">
			抱歉，您当前还未完善名片信息，快去完善吧
		</view> -->

		<view class="card-buts" @click="handeleImprovel">{{$t('去完善信息')}}</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				lang: 'zh',
				model: {
					username: '', //公司名称
					truename: '', //联系人（真实姓名）
					mobile: '', //联系电话
					idnum: '', //身份证号码
					area_id: [], //所在区域
					reg_address: '', //详细地址
					email: '', //邮箱
					fax: '', //传真
					weblink: '', //网站
					provide_transport: [], //运输工具
					transport_list: [{
						departureCity: '',
						arrivingCity: '',
						departureid: '',
						arrivingid: '',
						days: 0
					}], //运输路线
					main_product: '', //公司介绍
					product_image: [], //企业logo
					license_image: [], //营业执照 （资质证明）
					buy_videos: [], //企业宣传视频
					shop_image: [], //企业宣传图
					id: ''
				}
			}
		},
		onLoad(options) {
			this.id = options.id
			this.getLang()
			this.getData(options.id)
		},
		onShow() {
			if (this.id) {
				this.getData(this.id)
			}
		},
		methods: {
			getData(id) {
				let data = {
					user_id: id,
					type: 1,
					from: ''
				}
				this.$u.api.user.getUserHomepage(data).then(res => {
					let ared = []
					ared.push({
						label: this.lang == 'zh' ? res.userInfo.area_id.country_name : res.userInfo.area_id
							.country_name_ru,
						value: res.userInfo.area_id.country
					})
					ared.push({
						label: this.lang == 'zh' ? res.userInfo.area_id.province_name : res.userInfo
							.area_id.province_name_ru,
						value: res.userInfo.area_id.province
					})
					ared.push({
						label: this.lang == 'zh' ? res.userInfo.area_id.city_name : res.userInfo.area_id
							.city_name_ru,
						value: res.userInfo.area_id.city
					})
					let datas = {
						// country_name:res.userInfo.label[0].id,
						username: this.lang == 'zh' ? res.userInfo.username : res.userInfo.username_ru, //公司名称
						truename: this.lang == 'zh' ? res.userInfo.truename : res.userInfo
						.truename_ru, //联系人（真实姓名）
						mobile: res.userInfo.mobile, //联系电话
						idnum: res.userInfo.id_card, //身份证号码
						// label value
						area_id: ared, //所在区域
						reg_address: res.userInfo.reg_address, //详细地址
						email: res.userInfo.email, //邮箱
						fax: res.userInfo.fax, //传真
						weblink: res.userInfo.weblink, //网站
						// children id name user path
						provide_transport: res.userInfo.provide_transport.split(','), //运输工具
						transport_list: res.luxian.map(item => {
							return {
								departureCity: this.lang == 'zh' ? item.cfd.shortname : item.cfd
									.shortname_ru,
								arrivingCity: this.lang == 'zh' ? item.mdd.shortname : item.mdd
									.shortname_ru,
								departureid: item.cfd.id,
								arrivingid: item.mdd.id,
								days: 0
							}
						}),
						main_product: this.lang == 'zh' ? res.userInfo.main_product : res.userInfo
							.main_product_ru, //公司介绍
						product_image: res.userInfo.product_image, //企业logo
						license_image: res.userInfo.license_image2, //营业执照 （资质证明）

						buy_videos: [res.userInfo.buy_videos], //企业宣传视频
						shop_image: res.userInfo.shop_image, //企业宣传图
					}
					this.model = datas
					console.log('完善信息:', this.model);
				})
			},
			getLang() {
				// 获取缓存lang当前语言值
				uni.getStorage({
					key: 'lang',
					success: res => {
						if (res.data == 'zh') { //zh为中国，赋值0
							this.lang = 'zh'
						} else { //其他为俄罗斯，赋值1
							this.lang = 'ru'
						}
					}
				});
			},
			rightClick() {
				uni.navigateBack()
			},
			handeleImprovel() {
				uni.navigateTo({
					url: '/pages/tabbar/order/ImproveInformation?model=' + JSON.stringify(this.model)
				})
			}
		}
	}
</script>

<style scoped>
	.card-buts {
		margin-top: 299rpx;
		width: 544rpx;
		height: 80rpx;
		text-align: center;
		line-height: 80rpx;
		border-radius: 80rpx;
		background: linear-gradient(180deg, #30F998 0%, #0D7DE2 98%);
		color: #FFFFFF;
	}

	.card-content {
		width: 100%;
		height: 100%;
		display: flex;
		flex-direction: column;
		align-items: center;
	}
</style>